package com.sunk.springcloud.service.Impl;

import com.sunk.springcloud.dao.AccountDao;
import com.sunk.springcloud.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.concurrent.TimeUnit;

@Slf4j
@Service
public class AccountServiceImpl implements AccountService {
    @Resource
    AccountDao accountDao;

    @Override
    public void decrease(Long userId, BigDecimal money) throws InterruptedException {
        log.info("--------->account-service扣除账户余额开始");
        //模拟超时
        TimeUnit.SECONDS.sleep(20);
        accountDao.decrease(userId,money);
        log.info("--------->account-service扣除账户余额结束");
    }
}
